<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:78:"D:\phpstudy_pro\WWW\xqyw\public/../application/system\view\database\index.html";i:1705132398;s:65:"D:\phpstudy_pro\WWW\xqyw\application\system\view\public\head.html";i:1715411275;s:67:"D:\phpstudy_pro\WWW\xqyw\application\system\view\public\footer.html";i:1704857607;}*/ ?>
<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>后台管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" href="/static/system/images/favicon.ico">
	<link rel="stylesheet" href="/static/system/css/themes/default.css" media="all">
	<link rel="stylesheet" href="/static/system/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
	<link rel="stylesheet" href="/static/system/lib/layui-v2.9.9/css/layui.css" media="all">
	<link rel="stylesheet" href="/static/system/css/public.css" media="all">
	<link rel="stylesheet" href="/static/system/css/layuimini.css?v=2.0.4.2" media="all">

	<script src="/static/system/lib/layui-v2.9.9/layui.js" charset="utf-8"></script>
	<script src="/static/system/js/lay-config.js?v=2.0.0" charset="utf-8"></script>
	<script>
        // 是否开启刷新记忆tab功能
        // var is_remember = false;
    </script>
	<!--[if lt IE 9]>
		<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
		<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
	<style id="layuimini-bg-color">
	</style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <blockquote class="layui-elem-quote">
                数据库中共有<i class="count"></i>张表，共计<i class="size"></i>
                <a href="javascript:void(0)" id="backUp" class="layui-btn layui-btn-xs layui-bg-blue pull-right">备份</a>
            </blockquote>
            <table class="layui-table" id="list" lay-filter="list"></table>
    </div>
</div>
<script type="text/html" id="action">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="optimize">优化</a>
    <a class="layui-btn layui-btn-xs layui-btn-primary layui-border" lay-event="repair">修复</a>
</script>
<script>
    layui.use('table', function() {
        var table = layui.table, $ = layui.jquery;
        table.render({
            id: 'database',
            elem: '#list',
            url: '<?php echo url("index"); ?>',
            method: 'post',
            cols: [[
                {checkbox:true,fixed: true},
                {field: 'Name', title: '数据库表', width: 180, fixed: true,sort: true},
                {field: 'Rows', title: '记录条数', width: 150,sort: true},
                {field: 'size', title: '占用空间', width: 150,sort: true},
                {field: 'Engine', title: '类型', width: 100,sort: true},
                {field: 'Collation', title: '编码', width: 150,sort: true},
                {field: 'Create_time', title: '创建时间', width: 180,sort: true},
                {field: 'Comment', title: '说明'},
                {width: 150, align: 'center', toolbar: '#action'}
            ]],
            done: function(res, curr, count){
                $('.count').html(res.tableNum);
                $('.size').html(res.total);
            }
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            loading = layer.load(1, {shade: [0.1, '#fff']});
            if (obj.event === 'optimize') {
                $.post("<?php echo url('optimize'); ?>",{tableName:data.Name},function(res){
                    layer.close(loading);
                    if(res.code > 0){
                        layer.msg(res.msg,{time:1000,icon:1},function(){
                            window.location.href = '<?php echo url("index"); ?>';
                        });
                    }else{
                        layer.msg(res.msg,{time:1000,icon:2});
                    }
                });
            }else if(obj.event === 'repair'){
                $.post("<?php echo url('repair'); ?>",{tableName:data.Name},function(res){
                    layer.close(loading);
                    if(res.code > 0){
                        layer.msg(res.msg,{time:1000,icon:1},function(){
                            window.location.href = '<?php echo url("index"); ?>';
                        });
                    }else{
                        layer.msg(res.msg,{time:1000,icon:2});
                    }
                });
            }
        });

        $('#backUp').click(function(){
            var obj = $(this);
            var checkStatus = table.checkStatus('database'); //test即为参数id设定的值
            var a = [];
            $(checkStatus.data).each(function(i,o){
                a.push(o.Name);
            });
            obj.addClass('layui-btn-disabled');
            obj.html('备份进行中...');
            $.post("<?php echo url('backup'); ?>",{tables:a},function(data){
                if(data.code==1){
                    obj.removeClass('layui-btn-disabled');
                    obj.html('备份');
                    layer.msg(data.msg,{time:1000,icon:1});
                }else{
                    layer.msg(data.msg,{time:1000,icon:2});
                }
            });
        })
    });
</script>
<script>
    layui.use(['jquery', 'layer', 'miniAdmin'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            miniAdmin = layui.miniAdmin,
            iniUrl = {};
        var options = {
            iniUrl: "<?php echo url('index/getSystemInit'); ?>", // 初始化接口
            clearUrl: "clear", // 缓存清理接口
            urlHashLocation: true, // 是否打开hash定位
            bgColorDefault: false, // 主题默认配置
            multiModule: true, // 是否开启多模块
            menuChildOpen: false, // 是否默认展开菜单
            loadingTime: 0, // 初始化加载时间
            pageAnim: true, // iframe窗口动画
            maxTabNum: 20, // 最大的tab打开数量
        };
        miniAdmin.render(options);
        $('.login-out').on("click", function () {
            $.post("<?php echo url('Login/outlogin'); ?>",{},function(res) {
                layer.msg('退出登录成功', function () {
                    window.location = 'Login/index';
                });
            })

        });
    });
</script>
<script>
    //预览大小根据原图的大小决定弹窗的大小
    function previewImg(obj) {
        var img = new Image();
        img.src = obj.src;
        var height = img.height + 50; //获取图片高度
        var width = img.width; //获取图片宽度
        var imgHtml = "<img src='" + obj.src + "' width='100%' height='100%'/>";
        //弹出层
        layer.open({
            type: 1,
            shade: 0.8,
            offset: 'auto',
            // area: [height + 'px', width + 'px'],
            area: ['800px', '600px'],
            shadeClose: true,
            scrollbar: false,
            title: '', //不显示标题
            content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            cancel: function () {
                //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });
            }
        });
    }
</script>
</body>

</html>